package cn.tenghw.redission;
import org.redisson.Redisson;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class RedissionDemoApplication {
	@Value("${spring.redis.host}")
	private String address;
	@Value("${spring.redis.port}")
	private String port;
	@Value("${spring.redis.password}")
	private String password;


	@Bean
	public Redisson redisson(){
		// 单机模式
		Config config = new Config();
		config.useSingleServer()
				//.setAddress("redis://127.0.0.1:6379")
				.setAddress("redis://"+address+":"+port)
				.setPassword(password)
				.setDatabase(0);
		return (Redisson) Redisson.create(config);
	}

	public static void main(String[] args) {

		SpringApplication.run(RedissionDemoApplication.class, args);
	}

}
